package com.wantupai.mvp.mvp.lce;

import android.support.annotation.DrawableRes;
import android.view.View;

import com.wantupai.mvp.R;
import com.wantupai.mvp.mvp.MvpView;
import com.wantupai.mvp.mvp.lce.animcator.DefaultMvpAnimator;

import ezy.ui.layout.LoadingLayout;


/**
 * @author :Created by zhangqing on 2018/11/26 13:16
 * @description :
 * @email :1423118197@qq.com
 * @classpath : com.football.wealth.mvp.impl.lce.MvpViewImpl
 */
public class MvpViewImpl<D> implements MvpView<D>
{

    private LoadingLayout mLoadingLayout;


    public void initView(View view)
    {
        if (view == null)
        {
            throw new NullPointerException("mLoadingLayout  不能给为空");
        }
        if (mLoadingLayout == null)
        {
            mLoadingLayout = (LoadingLayout) view.findViewById(R.id.loadingView);
        }
    }

    protected IMvpAnimator mIMvpAnimator;

    public IMvpAnimator getAnimator()
    {
        if (mIMvpAnimator == null)
        {
            mIMvpAnimator = new DefaultMvpAnimator();
        }
        return mIMvpAnimator;
    }

    public void setOnClickErrorListener(View.OnClickListener onClickErrorListener)
    {
        if (mLoadingLayout != null)
        {
            mLoadingLayout.setErrorClickListener(onClickErrorListener);
        }
    }


    @Override
    public void showLoading(boolean isPullToRefresh)
    {

    }

    @Override
    public void loadData(boolean isPullToRefresh)
    {

    }

    @Override
    public void showContent()
    {
        if (mLoadingLayout != null)
        {
            mLoadingLayout.showContent();
        }
    }

    @Override
    public void bindData(D d)
    {
        if (mLoadingLayout != null)
        {
            mLoadingLayout.showContent();
        }
    }

    public void setEmptyImageView(@DrawableRes int imageResourcesId)
    {
        if (mLoadingLayout != null)
        {
            mLoadingLayout.setEmptyImage(imageResourcesId);
        }
    }


    public void setEmptyTextView(CharSequence charSequence)
    {
        if (mLoadingLayout != null)
        {
            mLoadingLayout.setEmptyText(charSequence.toString());
        }
    }

    @Override
    public void showError()
    {
        if (mLoadingLayout != null)
        {
            mLoadingLayout.showError();
        }
    }

    @Override
    public void showEmpty()
    {
        if (mLoadingLayout != null)
        {
            mLoadingLayout.showEmpty();
        }
    }


    @Override
    public void showNetWorkError()
    {

    }


    @Override
    public void showLoadingDialog()
    {

    }

    @Override
    public void dismissDialog()
    {

    }

}
